This workflow is designed to take raw Spot output (.csv file) and automatically perform:
√ Import csv file
√ Extraneous row deletion
√ Tripicate averaging
- Background subtraction
- Statistics (one-way ANOVA with post-hoc test)
- Data visualisation
install.packages("dplyr")
install.packages("tidyverse")
library(dplyr)
library(tidyverse)
setwd("/Volumes/DOOLAN_Research_Team-A13379/IMB team/LAB MEMBERS/JONATHAN TAN/Projects/ANOVA_tutorial/ANOVA_tutorial")
dir.create("plots")
dir.create("data")
read.csv("Data/P6_spots.csv", header = FALSE) # header = FALSE is included to avoid the error: more columns than column names
## V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11
## 1 GU001-P6.plt NA NA NA NA NA NA NA NA NA NA
## 2 enzymatic NA NA NA NA NA NA NA NA NA NA
## 3 Friday, September 06, 2024 11:51:51 NA NA NA NA NA NA NA NA NA NA
## 4 1 2 3 4 5 6 7 8 9 10
## 5 A 2 3 1 2 2 1 1 0 0 26
## 6 B 188 165 160 119 164 126 90 87 102 109
## 7 C 42 61 61 97 88 92 60 61 44 51
## 8 D 530 517 487 650 689 672 349 354 318 321
## 9 E 440 527 562 665 640 646 340 311 307 353
## 10 F 31 22 28 32 13 35 35 16 16 18
## 11 G 508 497 516 596 638 576 352 335 341 389
## 12 H 557 550 639 610 637 668 674 649 678 663
## V12 V13
## 1 NA NA
## 2 NA NA
## 3 NA NA
## 4 11 12
## 5 0 1
## 6 117 131
## 7 49 33
## 8 354 296
## 9 339 328
## 10 9 7
## 11 387 378
## 12 586 643
P6<-read.csv("Data/P6_spots.csv", header = FALSE) # Create a new variable (P6) and save the contents of the .csv file into that variable
P6_clean <- slice(P6, -c(1:4)) # Remove (slice) rows 1-4
colnames(P6_clean) <- c("Plate_rows", "Mouse1_r1","Mouse1_r2","Mouse1_r3","Mouse2_r1","Mouse2_r2","Mouse2_r3","Mouse3_r1","Mouse3_r2","Mouse3_r3","Mouse4_r1","Mouse4_r2","Mouse4_r3") # Change to meaningful header names (r1 = replicate 1)
print (P6_clean)
## Plate_rows Mouse1_r1 Mouse1_r2 Mouse1_r3 Mouse2_r1 Mouse2_r2 Mouse2_r3
## 1 A 2 3 1 2 2 1
## 2 B 188 165 160 119 164 126
## 3 C 42 61 61 97 88 92
## 4 D 530 517 487 650 689 672
## 5 E 440 527 562 665 640 646
## 6 F 31 22 28 32 13 35
## 7 G 508 497 516 596 638 576
## 8 H 557 550 639 610 637 668
## Mouse3_r1 Mouse3_r2 Mouse3_r3 Mouse4_r1 Mouse4_r2 Mouse4_r3
## 1 1 0 0 26 0 1
## 2 90 87 102 109 117 131
## 3 60 61 44 51 49 33
## 4 349 354 318 321 354 296
## 5 340 311 307 353 339 328
## 6 35 16 16 18 9 7
## 7 352 335 341 389 387 378
## 8 674 649 678 663 586 643
# write.csv(P6_clean, "Data/P6_clean.csv")
P6_average <- pivot_longer(P6_clean, cols = starts_with("M"), names_to = "replicates", values_to = "counts") |> # Convert dataframe into "Tall format" by concatenating columns (MouseX_rX) into one column (replicates)
mutate(group = gsub(pattern = "\\_r[1|2|3]", replacement = "", x = replicates)) |> # Search/match headers for the characters/pattern xxx_r1 etc, substitute/replace with nothing "" (ie. Mouse1). Search within "replicates"
group_by(Plate_rows, group) |> mutate(avg = mean(counts)) |>
distinct(Plate_rows,group,avg) |>
pivot_wider(id_cols = Plate_rows, names_from = group, values_from = avg) |> as.data.frame()
print (P6_average)
## Plate_rows Mouse1 Mouse2 Mouse3 Mouse4
## 1 A 2.00000 1.666667 0.3333333 9.00000
## 2 B 171.00000 136.333333 93.0000000 119.00000
## 3 C 54.66667 92.333333 55.0000000 44.33333
## 4 D 511.33333 670.333333 340.3333333 323.66667
## 5 E 509.66667 650.333333 319.3333333 340.00000
## 6 F 27.00000 26.666667 22.3333333 11.33333
## 7 G 507.00000 603.333333 342.6666667 384.66667
## 8 H 582.00000 638.333333 667.0000000 630.66667
The purpose of this step is to subtract “Media only” spot counts from Peptide and ConA stimulation wells, and to subtract A20-empty_vector counts from A20-CSP wells. The stimulants correspond to the following Plate_rows:
A(1) = Media only
B(2) = Peptide (57-70)
C(3) = Peptide (58-67)
D(4) = Peptide (280-288)
E(5) = Peptide (280-295)
F(6) = A20 (EV)
G(7) = A20 (CSP)
H(8) = ConA
We will start by selecting the rows we are subtracting from (eg. Peptides and ConA corresponding to rows [2:5, 8]), creating another dataframe with “Media only” data (row 1, replicated 5 times), then subtracting one df from the other.
P6_peptide <- P6_average[c(2:5, 8), -1]- P6_average[rep(1,5),-1] # remove first column (-1)
print (P6_peptide)
## Mouse1 Mouse2 Mouse3 Mouse4
## 2 169.00000 134.66667 92.66667 110.00000
## 3 52.66667 90.66667 54.66667 35.33333
## 4 509.33333 668.66667 340.00000 314.66667
## 5 507.66667 648.66667 319.00000 331.00000
## 8 580.00000 636.66667 666.66667 621.66667
Repeat this for A20 subtraction:
P6_A20 <- P6_average[7, -1]- P6_average[6, -1] # remove first column (-1)
print (P6_A20)
## Mouse1 Mouse2 Mouse3 Mouse4
## 7 480 576.6667 320.3333 373.3333
And merge the dataframes together!
P6_subtracted <- rbind(P6_peptide, P6_A20)
print (P6_subtracted)
## Mouse1 Mouse2 Mouse3 Mouse4
## 2 169.00000 134.66667 92.66667 110.00000
## 3 52.66667 90.66667 54.66667 35.33333
## 4 509.33333 668.66667 340.00000 314.66667
## 5 507.66667 648.66667 319.00000 331.00000
## 8 580.00000 636.66667 666.66667 621.66667
## 7 480.00000 576.66667 320.33333 373.33333